/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.auto.ibatis;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ConfigReviewDAO;
import com.alipay.supergw.common.dal.share_supergw.auto.dataobject.ConfigReviewDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.ConfigReviewDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_config_review.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisConfigReviewDAO extends SqlMapClientDaoSupport implements ConfigReviewDAO {

    /**
     *  Insert one <tt>ConfigReviewDO</tt> object to DB table <tt>sgw_config_review</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_config_review(id,status,operate_type,alter_file_path,operator,checker,gmt_create,gmt_modified,memo) values (?, ?, ?, ?, ?, ?, sysdate, sysdate, ?)</tt>
     *
     *	@param configReview
     *	@return int
     *	@throws DataAccessException
     */
    public int insert(ConfigReviewDO configReview) throws DataAccessException {
        if (configReview == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-CONFIG-REVIEW-INSERT", configReview);

        return configReview.getId();
    }

    /**
     *  Query DB table <tt>sgw_config_review</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, status, operate_type, alter_file_path, operator, checker, gmt_create, gmt_modified, memo from sgw_config_review where ((gmt_create > ?) AND (gmt_create < ?) AND (id = ?) AND (status = ?) AND (operate_type = ?) AND (alter_file_path = ?)) order by gmt_create DESC</tt>
     *
     *	@param gmtCreate
     *	@param gmtCreate2
     *	@param id
     *	@param status
     *	@param operateType
     *	@param alterFilePath
     *	@return List<ConfigReviewDO>
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public List<ConfigReviewDO> select(Date gmtCreate, Date gmtCreate2, String status,
                                       String operateType, String alterFilePath)
                                                                                throws DataAccessException {
        Map param = new HashMap();

        param.put("gmtCreate", gmtCreate);
        param.put("gmtCreate2", gmtCreate2);
        param.put("status", status);
        param.put("operateType", operateType);
        param.put("alterFilePath", alterFilePath);

        return getSqlMapClientTemplate().queryForList("MS-CONFIG-REVIEW-SELECT", param);

    }

    /**
     *  Update DB table <tt>sgw_config_review</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_config_review set status=?, checker=?, memo=?, gmt_modified=sysdate where (id = ?)</tt>
     *
     *	@param status
     *	@param checker
     *	@param memo
     *	@param id
     *	@return int
     *	@throws DataAccessException
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public int update(String status, String checker, String memo, int id)
                                                                         throws DataAccessException {
        Map param = new HashMap();

        param.put("status", status);
        param.put("checker", checker);
        param.put("memo", memo);
        param.put("id", new Integer(id));

        return getSqlMapClientTemplate().update("MS-CONFIG-REVIEW-UPDATE", param);
    }

    /**
     *  Query DB table <tt>sgw_config_review</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, status, operate_type, alter_file_path, operator, checker, gmt_create, gmt_modified, memo from sgw_config_review where (id = ?)</tt>
     *
     *	@param id
     *	@return ConfigReviewDO
     *	@throws DataAccessException
     */
    public ConfigReviewDO selectById(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return (ConfigReviewDO) getSqlMapClientTemplate().queryForObject(
            "MS-CONFIG-REVIEW-SELECT-BY-ID", param);

    }

    /**
     *  Query DB table <tt>sgw_config_review</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select id, status, operate_type, alter_file_path, operator, checker, gmt_create, gmt_modified, memo from sgw_config_review where (id = ?) for update</tt>
     *
     *	@param id
     *	@return ConfigReviewDO
     *	@throws DataAccessException
     */
    public ConfigReviewDO selectByIdForUpdate(int id) throws DataAccessException {
        Integer param = new Integer(id);

        return (ConfigReviewDO) getSqlMapClientTemplate().queryForObject(
            "MS-CONFIG-REVIEW-SELECT-BY-ID-FOR-UPDATE", param);

    }

}